
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title> 一审</title>
  <link rel="stylesheet" type="text/css" href="/css/style.css" />

  <style type="text/css">
    *, body {
      margin: 0px;
      font-family: '微软雅黑';
    }
  </style>
  <script src="~/js/jquery-1.10.2.min.js"></script>
  <script src="~/js/generic.js"></script>
  <script src="~/js/fypage.js"></script>
</head>

<body>

@Html.Partial("top")

<table class="maintable">
  <tr>
    @Html.Partial("menu")
    <td class="rightmaintd" valign="top">
      <div class="searchdiv">
        @*<input type="button" id="btnAdd" style="display: none;" value="+添加医案" class="xinzengbtn" onclick="create()">*@

        <div style="float: left;">
          查询医案编号 <input type="text" id="biaohao" class="textinput_chaxun">  &nbsp; &nbsp;  &nbsp; &nbsp;
          医生姓名 <input type="text" id="yisheng" class="textinput_chaxun">  &nbsp; &nbsp;  &nbsp; &nbsp;
          患者姓名 <input type="text" id="xingming" class="textinput_chaxun">  &nbsp; &nbsp; &nbsp; &nbsp;
          <input type="button" value="查询医案" class="chaxunbtn" onclick="search();"><img src="/images/fdj.png" alt="" class="searchfdj"></button>
        </div>
      </div>
      <table class="neirontbiao" id="tbl_list"></table>


      <div class="pagediv" id="pager">
      </div>

    </td>
  </tr>
</table>

@Html.Partial("bottom")

</body>
</html>
<script type="text/javascript">
  var usertype = "@type";
  //编辑返回时的当前页
  var _old_Page = '@ViewBag.CurrPage';
  var submit = false;
  var pager;
  //定义全局变量来看是升序还是降序
  var asc = "1";
  var clickName = "医案编号";
  $(document).ready(function() {
    pager = new Fypager("pager", getList);
    //设置原始的页数=====begin======
    if (_old_Page != "" && _old_Page != null) {
      pager.currPage = _old_Page;
    }
    //设置原始的页数======end=====
    getList();
    //获得td的点击事件
    document.onmouseup = function (e) { //点击获取表格中的值
      var a = e.target.innerHTML;
      //当不是这几个值的时候就不进行值的重置
      if (a == "医案编号" || a == "医生" || a == "书名" || a == "章节" || a == "起始页" || a == "录入时间") {
        clickName = e.target.innerHTML;
      } else {
        asc = -asc;
      }
    }
  });

  function create() {
    location.href = "/FirstCheck/edit";
  }

  function update(userid) {
    //连接userid和当前页
    userid = userid + "-" + pager.currPage;
    location.href = "/FirstCheck/edit/" + userid;
  }

  function del(userid) {
    if (confirm("确认删除医案信息吗")) {
      util.post("/FirstCheck/delete", { "id": userid }, function (json) {
        if (json.status == 0) {
          getList();
        } else {
          alert(json.msg);
        }
      });
    }
  }

  function search() {
    pager.goPage(1);
    //location.href = "/yian/search?biaohao=" + encodeURI($("#keyword").val());
  }
  function Sort() {
    pager = new Fypager("pager", SortByItem);
    SortByItem();
  }
  //后台进行排序
  function SortByItem() {
    asc = -asc;
    var url = "/FirstCheck/GetListOrderByItem?pageIndex=" + pager.currPage;
    util.getJSON(url, { "biaohao": $("#biaohao").val(), "xingming": $("#xingming").val(), "yisheng": $("#yisheng").val(), "asc": asc, "Item": clickName, "zhongxiyi": "中医" }, function (json) {
      if (json.status == 0) {
        pager.showPager(json.totalPage, json.totalNum);
        showList(json.list);
      } else {
        alert(json.msg);
      }
    });
  }
  function getList() {
    var url = "/FirstCheck/GetList?pageIndex=" + pager.currPage;
    util.getJSON(url, { "biaohao": $("#biaohao").val(), "xingming": $("#xingming").val(), "yisheng": $("#yisheng").val(),"zhongxiyi":"中医" }, function (json) {
      if (json.status == 0) {
        pager.showPager(json.totalPage, json.totalNum);
        showList(json.list);
      } else {
        alert(json.msg);
      }
    });
  }

  function showList(list) {
    if (usertype != "名医专家") {
      $("#btnAdd").show();
    }
    var html = '<tr class="neirontbiaotou"><td  class="span-line" onclick="Sort()" width="10%">医案编号</td><td width="8%">患者姓名</td><td width="5%">性别</td><td width="5%">年龄</td><td width="14%">就诊时间</td><td  class="span-line" onclick="Sort()" width="9%">医生</td><td  class="span-line" onclick="Sort()" width="8%">书名</td><td  class="span-line" onclick="Sort()" width="8%">章节</td><td width="5%">条文序号</td><td  class="span-line" onclick="Sort()" width="5%">起始页</td><td width="5%">终止页</td><td width="10%">录入人</td><td  class="span-line" onclick="Sort()" width="10%">录入时间</td><td width="6%">审核</td><td width="10%"></td></tr>';
    if (list.length == 0) {
      html += '<tr><td colspan="10" style="text-align:center;height:50px;">暂无医案信息</td></tr>';
    }
    for (var i = 0; i < list.length; i++) {
      html += '<tr>';
      html += '<td title="' + list[i].bianhao + '">' + util.formateTitle(list[i].biaohao, 10, true) + '</td>';
      html += '<td>' + util.FormateNull(list[i].xingming) + '</td>';
      html += '<td>' + util.FormateNull(list[i].xingbie) + '</td>';
      html += '<td>' + util.FormateNull(list[i].nianling) + '</td>';

      html += '<td>' + util.FormateNull(util.formateDate(list[i].jiuzhenshijian, "yyyy-MM-dd")) + '</td>';
      html += '<td>' + util.FormateNull(list[i].jiuzhenyisheng) + '</td>';

      html += '<td>' + util.FormateNull(list[i].shuming) + '</td>';
      html += '<td>' + util.FormateNull(list[i].zhangjie) + '</td>';
      html += '<td>' + util.FormateNull(list[i].tiaowenxuhao) + '</td>';
      html += '<td title="' + list[i].yema + '">' + util.formateTitle(list[i].yema, 8, true) + '</td>';
      html += '<td title="' + list[i].yemaEnd + '">' + util.formateTitle(list[i].yemaEnd, 8, true) + '</td>';
      html += '<td>' + util.FormateNull(list[i].createuser) + '</td>';
      html += '<td>' + util.FormateNull(util.formateDate(list[i].createtime, "yyyy-MM-dd")) + '</td>';
      html += '<td>' + util.FormateNull(list[i].shenhe) + '</td>';

      if (list[i].shenhe == "提交") {
        if (list[i].yianid == null) {
          html += '<td>' + '<a href="javascript:update(\'' + list[i].id + '\')">一审</a>' + '</td></tr>';
        } else {
          html += '<td>' + '<a href="javascript:update(\'' + list[i].yianid + '\')">一审</a>' + '</td></tr>';
        }
        //html += '<td>' + '<a href="javascript:update(\'' + list[i].id + '\')">一审</a>' + '</td></tr>';
      }
      else if (list[i].shenhe == "一审") {
        if (list[i].yianid == null) {
          html += '<td>' + '<a href="javascript:update(\'' + list[i].id + '\')">二审</a>' + '</td></tr>';
        } else {
          html += '<td>' + '<a href="javascript:update(\'' + list[i].yianid + '\')">二审</a>' + '</td></tr>';
        }
        //html += '<td>' + '<a href="javascript:update(\'' + list[i].id + '\')">二审</a>' + '</td></tr>';
      }else {
        html += '<td>&nbsp;</td>';
      }
    }
    $("#tbl_list").html(html);
  }
</script>